﻿<?xml version="1.0" encoding="utf-8" ?>
<!--namespace必须用否者就报错（读取配置文件报：未将对象引用设置到对象的实例）-->
<sqlMap namespace="" xmlns="http://ibatis.apache.org/mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  <alias>
    <typeAlias alias="SupplierBase" type="Kaiser.Modules.Hiner.Models.Supplier.SupplierBase" />
    <typeAlias alias="ProductBase" type="Kaiser.Modules.Hiner.Models.Product.ProductBase" />
  </alias>

  <resultMaps>
    <resultMap id="SelSupplier" class="SupplierBase">
      <result property="SupplierId" column="SupplierId"/>
      <result property="SupplierName" column="SupplierName"/>
      <result property="SupplierCode" column="SupplierCode"/>
      <result property="SupplierEnglishName" column="SupplierEnglishName"/>
      <result property="SupplierTypeCode" column="SupplierTypeCode"/>
      <result property="SupplierRemittance" column="SupplierRemittance"/>
      <result property="SupplierLinkManName" column="SupplierLinkManName"/>
      <result property="SupplierLinkManCode" column="SupplierLinkManCode"/>
      <result property="SupplierContactWay" column="SupplierContactWay"/>
      <result property="SupplierAddress" column="SupplierAddress"/>
      <result property="SupplierTel" column="SupplierTel"/>
      <result property="SupplierDesc" column="SupplierDesc"/>
      <result property="SupplierClause" column="SupplierClause"/>
      <result property="LastModifyUserName" column="LastModifyUserName"/>
      <result property="LastModifyDateTime" column="LastModifyDateTime"/>
      <result property="LastModifyUserFullName" column="LastModifyUserFullName"/>
      <result property="CreateUserFullName" column="CreateUserFullName"/>
      <result property="CreateUserName" column="CreateUserName"/>
      <result property="CreateDateTime" column="CreateDateTime"/>
      <result property="ProductList" column="SupplierCode" select="GetProductBySupplierCode"/>
    </resultMap>
    <resultMap id="SelProduct" class="ProductBase">
      <result property="ProductId" column="ProductId"/>
      <result property="ProductName" column="ProductName"/>
      <result property="ProductSPEC" column="ProductSPEC"/>
      <result property="ProductHDECode" column="ProductHDECode"/>
      <result property="ProductHinerCode" column="ProductHinerCode"/>
      <result property="ProductOERef" column="ProductOERef"/>
      <result property="ProductCarModel" column="ProductCarModel"/>
      <result property="SupplierCode" column="SupplierCode"/>
      <result property="SupplierName" column="SupplierName"/>
      <result property="ProductSize" column="ProductSize"/>
      <result property="ProductDepict" column="ProductDepict"/>
      <result property="ProductImgUrl" column="ProductImgUrl"/>
      <result property="ProductPrice" column="ProductPrice"/>
      <result property="ProductCount" column="ProductCount"/>
      <result property="ProductDesc" column="ProductDesc"/>
      <result property="InnerPackageImgUrl" column="InnerPackageImgUrl"/>
      <result property="InnerPackageSize" column="InnerPackageSize"/>
      <result property="OuterPackageImgUrl" column="OuterPackageImgUrl"/>
      <result property="OuterPackageSize" column="OuterPackageSize"/>
      <result property="Nwt" column="Nwt"/>
      <result property="Gwt" column="Gwt"/>
      <result property="PcsCtn" column="PcsCtn"/>
      <result property="CWt" column="CWt"/>
      <result property="LastModifyUserName" column="LastModifyUserName"/>
      <result property="LastModifyDateTime" column="LastModifyDateTime"/>
      <result property="LastModifyUserFullName" column="LastModifyUserFullName"/>
      <result property="CreateUserFullName" column="CreateUserFullName"/>
      <result property="CreateUserName" column="CreateUserName"/>
      <result property="CreateDateTime" column="CreateDateTime"/>
    </resultMap>
  </resultMaps>


  <statements>

    <select id="GetSupplier" parameterClass="String" resultMap="SelSupplier">
      SELECT  * FROM [HINNER_Supplier] WHERE  [SupplierId]=#value#
    </select>

    <select id="GetProductBySupplierCode" parameterClass="int" resultMap="SelProduct">
      SELECT * FROM [HINNER_Product] where SupplierCode=#value#
    </select>

    <insert id="InsertConsignee" parameterClass="hashtable">
      INSERT INTO [HINNER_Consignee]
      ([ConsigneeId]
      ,[ConsigneeCode]
      ,[ConsigneeName]
      ,[ConsigneeAddress]
      ,[ConsigneeFax]
      ,[ConsigneeTel]
      ,[LastModifyUserName]
      ,[LastModifyDateTime]
      ,[LastModifyUserFullName]
      ,[CreateUserFullName]
      ,[CreateUserName]
      ,[CreateDateTime])
      VALUES
      (#ConsigneeId#
      ,#ConsigneeCode#
      ,#ConsigneeName#
      ,#ConsigneeAddress#
      ,#ConsigneeFax#
      ,#ConsigneeTel#
      ,#LastModifyUserName#
      ,#LastModifyDateTime#
      ,#LastModifyUserFullName#
      ,#CreateUserFullName#
      ,#CreateUserName#
      ,#CreateDateTime#)
    </insert>
    <update id="UpdateConsignee" parameterClass="hashtable" resultClass="int">
      UPDATE [HINNER_Consignee]
      SET [ConsigneeCode]=#ConsigneeCode#
      ,[ConsigneeName]=#ConsigneeName#
      ,[ConsigneeAddress]=#ConsigneeAddress#
      ,[ConsigneeFax]=#ConsigneeFax#
      ,[ConsigneeTel]=#ConsigneeTel#
      ,[LastModifyUserName]=#LastModifyUserName#
      ,[LastModifyDateTime]=#LastModifyDateTime#
      ,[LastModifyUserFullName]=#LastModifyUserFullName#
      ,[CreateUserFullName]=#CreateUserFullName#
      ,[CreateUserName]=#CreateUserName#
      ,[CreateDateTime]=#CreateDateTime#
      WHERE [ConsigneeId]=#ConsigneeId#
    </update>

    <delete id="DeleteConsigneeList" parameterClass="string" resultClass="int">
      DELETE FROM [HINNER_Consignee]  WHERE [ConsigneeId] in
      <iterate   property="ids" open="(" close=")"  conjunction=",">
        #ids[]#
      </iterate>
    </delete>
    <delete id="DeleteConsignee" parameterClass="string" resultClass="int">
      delete from [HINNER_Consignee]
      where  [ConsigneeId] = #ConsigneeId#
    </delete>
    <select id="SearchConsignee" resultClass="HashTable">
      SELECT [ConsigneeId]
      ,[ConsigneeCode]
      ,[ConsigneeName]
      ,[ConsigneeAddress]
      ,[ConsigneeFax]
      ,[ConsigneeTel]
      ,[LastModifyUserName]
      ,[LastModifyDateTime]
      ,[LastModifyUserFullName]
      ,[CreateUserFullName]
      ,[CreateUserName]
      ,[CreateDateTime]
      FROM [HINNER_Consignee]
      <dynamic prepend="where">
        <isParameterPresent>
          <isNotEmpty prepend="and" property="ConsigneeCode">
            [ConsigneeCode] like '%$ConsigneeCode$%'
          </isNotEmpty>
          <isNotEmpty prepend="and" property="ConsigneeName">
            [ConsigneeName] like '%$ConsigneeName$%'
          </isNotEmpty>
        </isParameterPresent>
      </dynamic>
    </select>

    <select id="GetConsignee" parameterClass="string" resultClass="Kaiser.Modules.Hiner.Models.Consignee.ConsigneeBase">
      SELECT [ConsigneeId]
      ,[ConsigneeCode]
      ,[ConsigneeName]
      ,[ConsigneeAddress]
      ,[ConsigneeFax]
      ,[ConsigneeTel]
      ,[LastModifyUserName]
      ,[LastModifyDateTime]
      ,[LastModifyUserFullName]
      ,[CreateUserFullName]
      ,[CreateUserName]
      ,[CreateDateTime]
      FROM [HINNER_Consignee]
      WHERE ConsigneeId=#ConsigneeId#
    </select>

    <insert id="InsertProductOrder" parameterClass="hashtable">
      INSERT INTO [HINNER_Order]
      ([OrderId]
      ,[ProductId]
      ,[OrderNo]
      ,[SupplierId]
      ,[OrderDate]
      ,[OrderDeliveryDate]
      ,[OrderContacts]
      ,[OrderContactsWay]
      ,[OrderPINo]
      ,[OrderPIFile]
      ,[OrderPrice]
      ,[OrderClause]
      ,[OrderStatus]
      ,[OrderOperator]
      ,[OrderOperatorID]
      ,[OrderOperatime]
      ,[OrderPayMentD]
      ,[OrderPayMentB]
      ,[LastModifyUserName]
      ,[LastModifyDateTime]
      ,[LastModifyUserFullName]
      ,[CreateUserFullName]
      ,[CreateUserName]
      ,[CreateDateTime])
      VALUES
      (#OrderId#
      ,#ProductId#
      ,#OrderNo#
      ,#SupplierId#
      ,#OrderDate#
      ,#OrderDeliveryDate#
      ,#OrderContacts#
      ,#OrderContactsWay#
      ,#OrderPINo#
      ,#OrderPIFile#
      ,#OrderPrice#
      ,#OrderClause#
      ,#OrderStatus#
      ,#OrderOperator#
      ,#OrderOperatorID#
      ,#OrderOperatime#
      ,#OrderPayMentD#
      ,#OrderPayMentB#
      ,#LastModifyUserName#
      ,#LastModifyDateTime#
      ,#LastModifyUserFullName#
      ,#CreateUserFullName#
      ,#CreateUserName#
      ,#CreateDateTime#)
    </insert>
    <update id="UpdateProductOrder" parameterClass="hashtable" resultClass="int">
      UPDATE [HINNER_Order]
      SET
      [ProductId]=#ProductId#
      ,[OrderNo]=#OrderNo#
      ,[SupplierId]=#SupplierId#
      ,[OrderDate]=#OrderDate#
      ,[OrderDeliveryDate]=#OrderDeliveryDate#
      ,[OrderContacts]=#OrderContacts#
      ,[OrderContactsWay]=#OrderContactsWay#
      ,[OrderPINo]=#OrderPINo#
      ,[OrderPIFile]=#OrderPIFile#
      ,[OrderPrice]=#OrderPrice#
      ,[OrderClause]=#OrderClause#
      ,[OrderStatus]=#OrderStatus#
      ,[OrderOperator]=#OrderOperator#
      ,[OrderOperatorID]=#OrderOperatorID#
      ,[OrderOperatime]=#OrderOperatime#
      ,[OrderPayMentD]=#OrderPayMentD#
      ,[OrderPayMentB]=#OrderPayMentB#
      ,[LastModifyUserName]=#LastModifyUserName#
      ,[LastModifyDateTime]=#LastModifyDateTime#
      ,[LastModifyUserFullName]=#LastModifyUserFullName#
      ,[CreateUserFullName]=#CreateUserFullName#
      ,[CreateUserName]=#CreateUserName#
      ,[CreateDateTime]=#CreateDateTime#
      WHERE [OrderId]=#OrderId#
    </update>
    <delete id="DeleteProductOrderList" parameterClass="string" resultClass="int">
      DELETE FROM [HINNER_Order]
      WHERE [OrderId] in
      <iterate   property="ids" open="(" close=")"  conjunction=",">
        #ids[]#
      </iterate>
    </delete>
    <delete id="DeleteProductOrder" parameterClass="string" resultClass="int">
      DELETE FROM [HINNER_Order]
      WHERE [OrderId]= #value#
    </delete>

    <insert id="InsertOrderDetail" parameterClass="hashtable">
      INSERT INTO [HINNER_OrderDetail]
      ([OrderDetailId]
      ,[OrderId]
      ,[ProductId]
      ,[ProductName]
      ,[Quantity]
      ,[ProductPrice]
      ,[CreateDateTime])
      VALUES
      (#OrderDetailId#
      ,#OrderId#
      ,#ProductId#
      ,#ProductName#
      ,#Quantity#
      ,#ProductPrice#
      ,#OrderDetailCreateDateTime#
      )
    </insert>
    <delete id="DeleteOrderDetail" parameterClass="string" resultClass="int">
      DELETE FROM [HINNER_OrderDetail]
      WHERE [OrderId]= #OrderId#
    </delete>

    <select id="GetOrderDetailList" parameterClass="string" resultClass="Kaiser.Modules.Hiner.Models.Order.OrderDetail">
      select *,HINNER_OrderDetail.CreateDateTime as OrderDetailCreateDateTime from HINNER_OrderDetail,HINNER_Product
      where HINNER_Product.ProductId=HINNER_OrderDetail.ProductId

      and OrderId=#value#
    </select>

    <select id="GetProductBase" parameterClass="string"   resultClass="HashTable">
      select * from HINNER_Product
      where ProductHDECode='$param0$'

    </select>

    <select id="SearchProductOrder" parameterClass="Kaiser.Modules.Hiner.Models.Order.SearchModels.OrderSearch" resultClass="HashTable">
      SELECT t1.[OrderId]
      ,t1.[ProductId]
      ,t1.[OrderNo]
      ,t1.[SupplierId]
      ,t2.SupplierName
      ,t1.[OrderDate]
      ,t1.[OrderDeliveryDate]
      ,t1.[OrderContacts]
      ,t1.[OrderContactsWay]
      ,t1.[OrderPINo]
      ,t1.[OrderPIFile]
      ,t1.[OrderPrice]
      ,t1.[OrderClause]
      ,t1.[OrderStatus]
      ,t1.[OrderOperator]
      ,t1.[OrderOperatorID]
      ,t1.[OrderOperatime]
      ,t1.[OrderPayMentD]
      ,t1.[OrderPayMentB]
      ,t1.[LastModifyUserName]
      ,t1.[LastModifyDateTime]
      ,t1.[LastModifyUserFullName]
      ,t1.[CreateUserFullName]
      ,t1.[CreateUserName]
      , t1.[CreateDateTime]
      FROM [HINNER_Order] t1
      left join HINNER_Supplier t2 on t1.SupplierId = t2.SupplierId
      left join dbo.HINNER_Product t3 on t1.ProductId=t3.ProductId
      left join dbo.HINNER_Order t4 on t1.OrderId=t4.OrderId
      <dynamic prepend="where">
        <isParameterPresent>
          <isNotEmpty prepend="and" property="ProductHDECode">
            t3.[ProductHDECode] like '%$ProductHDECode$%'
          </isNotEmpty>
          <isNotEmpty prepend="and" property="ProductHinerCode">
            t3.[ProductHinerCode] like '%$ProductHinerCode$%'
          </isNotEmpty>
          <isNotEmpty prepend="and" property="ProductOERef">
            t3.[ProductOERef] like '%$ProductOERef$%'
          </isNotEmpty>
          <isNotEmpty prepend="and" property="SupplierCode">
            t3.[SupplierCode] = '$SupplierCode$'
          </isNotEmpty>
          <isNotEmpty prepend="and" property="OrderNo">
            t1.[OrderNo] like '%$OrderNo$%'
          </isNotEmpty>
          <isNotEmpty prepend="and" property="OrderContacts">
            t1.[OrderContacts] like '%$OrderContacts$%'
          </isNotEmpty>
          <isNotEmpty prepend="and" property="OrderStatus">
            t1.[OrderStatus] = '$OrderStatus$'
          </isNotEmpty>
          <isNotEmpty prepend="and" property="MinPrice">
            t1.[OrderPrice] &gt;=$MinPrice$
          </isNotEmpty>
          <isNotEmpty prepend="and" property="MaxPrice">
            t1.[OrderPrice] &lt;=$MaxPrice$
          </isNotEmpty>
          <isNotEmpty prepend="and" property="StartTime">
            t1.[OrderDate] &gt;=$StartTime$
          </isNotEmpty>
          <isNotEmpty prepend="and" property="EndTime">
            t1.[OrderDate] &lt;=$EndTime$
          </isNotEmpty>
          <isNotEmpty prepend="and" property="SumbitStartTime">
            t1.[OrderDeliveryDate] &gt;=$SumbitStartTime$
          </isNotEmpty>
          <isNotEmpty prepend="and" property="SumbitEndTime">
            t1.[OrderDeliveryDate] &lt;=$SumbitEndTime$
          </isNotEmpty>
        </isParameterPresent>
      </dynamic>

      order by t1.[OrderDate] desc
    </select>

    <select id="GetProductOrder" parameterClass="string" resultClass="Kaiser.Modules.Hiner.Models.Order.OrderBase">
      SELECT [OrderId]
      ,[ProductId]
      ,[OrderNo]
      ,[SupplierId]
      ,[OrderDate]
      ,[OrderDeliveryDate]
      ,[OrderContacts]
      ,[OrderContactsWay]
      ,[OrderPINo]
      ,[OrderPIFile]
      ,[OrderPrice]
      ,[OrderClause]
      ,[OrderStatus]
      ,[OrderOperator]
      ,[OrderOperatorID]
      ,[OrderOperatime]
      ,[OrderPayMentD]
      ,[OrderPayMentB]
      ,[LastModifyUserName]
      ,[LastModifyDateTime]
      ,[LastModifyUserFullName]
      ,[CreateUserFullName]
      ,[CreateUserName]
      ,[CreateDateTime]
      FROM [HINNER_Order]
      WHERE OrderId=#value#
    </select>

    <select id="GetProductPhotoList" parameterClass="string" resultClass="Kaiser.Modules.Hiner.Models.Product.Photo">
      select Attach_FileName as Name,Attach_Path as SourceUrl from Attachment
      where Attach_ObjectID=#value# and Attach_ObjectModule = 'HinnerProductPhoto'
    </select>

    <insert id="InsertProduct" parameterClass="hashtable">
      INSERT INTO [HINNER_Product]
      (
      [ProductId]
      ,[ProductName]
      ,[ProductSPEC]
      ,[ProductHDECode]
      ,[ProductHinerCode]
      ,[ProductOERef]
      ,[ProductCarModel]
      ,[SupplierCode]
      ,[SupplierName]
      ,[ProductSize]
      ,[ProductDepict]
      ,[ProductImgUrl]
      ,[ProductPrice]
      ,[ProductCount]
      ,[ProductDesc]
      ,[InnerPackageImgUrl]
      ,[ProductImgName]
      ,[OuterPackageImgName]
      ,[InnerPackageImgName]
      ,[InnerPackageSize]
      ,[OuterPackageImgUrl]
      ,[OuterPackageSize]
      ,[Nwt]
      ,[Gwt]
      ,[PcsCtn]
      ,[CWt]
      ,[LastModifyUserName]
      ,[LastModifyDateTime]
      ,[LastModifyUserFullName]
      ,[CreateUserFullName]
      ,[CreateUserName]
      ,[CreateDateTime]
      ,[LabelImgUrl]
      )
      VALUES
      (
      #ProductId#
      ,#ProductName#
      ,#ProductSPEC#
      ,#ProductHDECode#
      ,#ProductHinerCode#
      ,#ProductOERef#
      ,#ProductCarModel#
      ,#SupplierCode#
      ,#SupplierName#
      ,#ProductSize#
      ,#ProductDepict#
      ,#ProductImgUrl#
      ,#ProductPrice#
      ,#ProductCount#
      ,#ProductDesc#
      ,#InnerPackageImgUrl#
      ,#ProductImgName#
      ,#OuterPackageImgName#
      ,#InnerPackageImgName#
      ,#InnerPackageSize#
      ,#OuterPackageImgUrl#
      ,#OuterPackageSize#
      ,#Nwt#
      ,#Gwt#
      ,#PcsCtn#
      ,#CWt#
      ,#LastModifyUserName#
      ,#LastModifyDateTime#
      ,#LastModifyUserFullName#
      ,#CreateUserFullName#
      ,#CreateUserName#
      ,#CreateDateTime#
      ,#LabelImgUrl#
      )
    </insert>
    <update id="UpdateProduct" parameterClass="hashtable" resultClass="int">
      UPDATE [HINNER_Product]
      SET
      [ProductId] =#ProductId#
      ,[ProductName] =#ProductName#
      ,[ProductSPEC] =#ProductSPEC#
      ,[ProductHDECode] =#ProductHDECode#
      ,[ProductHinerCode] =#ProductHinerCode#
      ,[ProductOERef] =#ProductOERef#
      ,[ProductCarModel] =#ProductCarModel#
      ,[SupplierCode] =#SupplierCode#
      ,[SupplierName] =#SupplierName#
      ,[ProductSize] =#ProductSize#
      ,[ProductDepict] =#ProductDepict#
      ,[ProductImgUrl] =#ProductImgUrl#
      ,[ProductPrice] =#ProductPrice#
      ,[ProductCount] =#ProductCount#
      ,[ProductDesc] =#ProductDesc#
      ,[InnerPackageImgUrl] =#InnerPackageImgUrl#
      ,[ProductImgName] =#ProductImgName#
      ,[OuterPackageImgName] =#OuterPackageImgName#
      ,[InnerPackageImgName] =#InnerPackageImgName#
      ,[InnerPackageSize] =#InnerPackageSize#
      ,[OuterPackageImgUrl] =#OuterPackageImgUrl#
      ,[OuterPackageSize] =#OuterPackageSize#
      ,[Nwt] =#Nwt#
      ,[Gwt] =#Gwt#
      ,[PcsCtn] =#PcsCtn#
      ,[CWt] =#CWt#
      ,[LastModifyUserName] =#LastModifyUserName#
      ,[LastModifyDateTime] =#LastModifyDateTime#
      ,[LastModifyUserFullName] =#LastModifyUserFullName#
      ,[CreateUserFullName] =#CreateUserFullName#
      ,[CreateUserName] =#CreateUserName#
      ,[CreateDateTime] =#CreateDateTime#
      ,[LabelImgUrl]=#LabelImgUrl#
      WHERE  [ProductId] =#ProductId#
    </update>
    <delete id="DeleteProductList" parameterClass="string" resultClass="int">
      DELETE FROM [HINNER_Product]
      WHERE [ProductId]  in
      <iterate   property="ids" open="(" close=")"  conjunction=",">
        #ids[]#
      </iterate>
    </delete>
    <delete id="DeleteProduct" parameterClass="string" resultClass="int">
      DELETE FROM [HINNER_Product]
      WHERE [ProductId] =#ProductId#
    </delete>

    <select id="SearchProduct" parameterClass="Kaiser.Modules.Hiner.Models.Product.SearchModels.ProductSearch" resultClass="HashTable">
      SELECT
      [ProductId]
      ,[ProductName]
      ,[ProductSPEC]
      ,[ProductHDECode]
      ,[ProductHinerCode]
      ,[ProductOERef]
      ,[ProductCarModel]
      ,[SupplierCode]
      ,[SupplierName]
      ,[ProductSize]
      ,[ProductDepict]
      ,[ProductImgUrl]
      ,[ProductPrice]
      ,[ProductCount]
      ,[ProductDesc]
      ,[InnerPackageImgUrl]
      ,[InnerPackageSize]
      ,[OuterPackageImgUrl]
      ,[OuterPackageSize]
      ,[LastModifyUserName]
      ,[LastModifyDateTime]
      ,[LastModifyUserFullName]
      ,[CreateUserFullName]
      ,[CreateUserName]
      ,[CreateDateTime]
      ,[LabelImgUrl]
      FROM  [HINNER_Product]
      <dynamic prepend="where">
        <isParameterPresent>
          <isNotEmpty prepend="and" property="ProductHDECode">
            [ProductHDECode] like '%$ProductHDECode$%'
          </isNotEmpty>
          <isNotEmpty prepend="and" property="ProductHinerCode">
            [ProductHinerCode] like '%$ProductHinerCode$%'
          </isNotEmpty>
          <isNotEmpty prepend="and" property="ProductOERef">
            [ProductOERef] like '%$ProductOERef$%'
          </isNotEmpty>
          <isNotEmpty prepend="and" property="SupplierCode">
            [SupplierCode] = '$SupplierCode$'
          </isNotEmpty>
          <isNotEmpty prepend="and" property="MinPrice">
            [ProductPrice] &gt;=$MinPrice$
          </isNotEmpty>
          <isNotEmpty prepend="and" property="MaxPrice">
            [ProductPrice] &lt;=$MaxPrice$
          </isNotEmpty>

        </isParameterPresent>
      </dynamic>
      <dynamic prepend=" order by ">
        <isPropertyAvailable property="orderStr">
          <isNull property="orderStr">
            CreateDateTime desc
          </isNull>
        </isPropertyAvailable>
      </dynamic>

    </select>

    <select id="GetProductList" parameterClass="Kaiser.Modules.Hiner.Models.Product.SearchModels.ProductSearch" resultClass="HashTable">
      select * from [HINNER_Product]
      <dynamic prepend="where">
        <isParameterPresent>
          <isNotEmpty prepend="and" property="ProductHDECode">
            [ProductHDECode] = '$ProductHDECode$'
          </isNotEmpty>
          <isNotEmpty prepend="and" property="ProductHinerCode">
            [ProductHinerCode] = '$ProductHinerCode$'
          </isNotEmpty>
          <isNotEmpty prepend="and" property="ProductId">
            [ProductId] &lt;&gt; '$ProductId$'
          </isNotEmpty>
        </isParameterPresent>
      </dynamic>
    </select>

    <select id="GetProduct" parameterClass="string" resultClass="Kaiser.Modules.Hiner.Models.Product.ProductBase">
      SELECT
      *
      FROM [HINNER_Product]
      WHERE  [ProductId]=#ProductId#
    </select>



    <insert id="InsertSupplier" parameterClass="hashtable">
      INSERT INTO [HINNER_Supplier]
      (
      [SupplierId]
      ,[SupplierCode]
      ,[SupplierName]
      ,[SupplierLinkManName]
      ,[SupplierLinkManCode]
      ,[SupplierContactWay]
      ,[SupplierAddress]
      ,[SupplierDesc]
      ,[SupplierClause]
      ,[SupplierEnglishName]
      ,[SupplierTypeCode]
      ,[SupplierRemittance]
      ,[SupplierFax]
      ,[SupplierTel]
      ,[LastModifyUserName]
      ,[LastModifyDateTime]
      ,[LastModifyUserFullName]
      ,[CreateUserFullName]
      ,[CreateUserName]
      ,[CreateDateTime]
      )
      VALUES
      (
      #SupplierId#
      ,#SupplierCode#
      ,#SupplierName#
      ,#SupplierLinkManName#
      ,#SupplierLinkManCode#
      ,#SupplierContactWay#
      ,#SupplierAddress#
      ,#SupplierDesc#
      ,#SupplierClause#
      ,#SupplierEnglishName#
      ,#SupplierTypeCode#
      ,#SupplierRemittance#
      ,#SupplierFax#
      ,#SupplierTel#
      ,#LastModifyUserName#
      ,#LastModifyDateTime#
      ,#LastModifyUserFullName#
      ,#CreateUserFullName#
      ,#CreateUserName#
      ,#CreateDateTime#
      )
    </insert>
    <update id="UpdateSupplier" parameterClass="hashtable" resultClass="int">
      UPDATE [HINNER_Supplier]
      SET
      [SupplierId] =#SupplierId#
      ,[SupplierCode] =#SupplierCode#
      ,[SupplierName] =#SupplierName#
      ,[SupplierLinkManName] =#SupplierLinkManName#
      ,[SupplierLinkManCode] =#SupplierLinkManCode#
      ,[SupplierContactWay] =#SupplierContactWay#
      ,[SupplierAddress] =#SupplierAddress#
      ,[SupplierDesc] =#SupplierDesc#
      ,[SupplierClause] =#SupplierClause#
      ,[SupplierEnglishName] =#SupplierEnglishName#
      ,[SupplierTypeCode] =#SupplierTypeCode#
      ,[SupplierRemittance] =#SupplierRemittance#
      ,[SupplierFax] =#SupplierFax#
      ,[SupplierTel] =#SupplierTel#
      ,[LastModifyUserName] =#LastModifyUserName#
      ,[LastModifyDateTime] =#LastModifyDateTime#
      ,[LastModifyUserFullName] =#LastModifyUserFullName#
      ,[CreateUserFullName] =#CreateUserFullName#
      ,[CreateUserName] =#CreateUserName#
      ,[CreateDateTime] =#CreateDateTime#

      WHERE  [SupplierId] =#SupplierId#
    </update>
    <delete id="DeleteSupplierList" parameterClass="string" resultClass="int">
      DELETE FROM [HINNER_Supplier]
      WHERE [SupplierId]  in
      <iterate   property="ids" open="(" close=")"  conjunction=",">
        #ids[]#
      </iterate>
    </delete>
    <delete id="DeleteSupplier" parameterClass="string" resultClass="int">
      DELETE FROM [HINNER_Supplier]
      WHERE [SupplierId] =#SupplierId#
    </delete>

    <select id="SearchSupplier" resultClass="HashTable">
      SELECT [SupplierId]
      ,[SupplierCode]
      ,[SupplierName]
      ,[SupplierLinkManName]
      ,[SupplierLinkManCode]
      ,[SupplierContactWay]
      ,[SupplierAddress]
      ,[SupplierDesc]
      ,[SupplierClause]
      ,[LastModifyUserName]
      ,[LastModifyDateTime]
      ,[LastModifyUserFullName]
      ,[CreateUserFullName]
      ,[CreateUserName]
      ,[CreateDateTime]
      FROM [HINNER_Supplier]
      <dynamic prepend="where">
        <isParameterPresent>
          <isNotEmpty prepend="and" property="SupplierName">
            [SupplierName] like '%$SupplierName$%'
          </isNotEmpty>
          <isNotEmpty prepend="and" property="SupplierCode">
            [SupplierCode] like '%$SupplierCode$%'
          </isNotEmpty>
        </isParameterPresent>
      </dynamic>
    </select>



    <!--上传附件开始 何航-->
    <select id="SearchAttachment" resultClass="HashTable">
      SELECT [Attach_ID]
      ,[Attach_FileName]
      ,[Attach_Path]
      ,[Attach_ObjectID]
      ,[Attach_ObjectModule]
      ,[Attach_ContentType]
      ,[Attach_Size]
      ,[Attach_IsTemp]
      ,[Attach_CreateTime]
      ,[Attach_CreateUserName]
      FROM [Attachment]
      <dynamic prepend="where">
        <isParameterPresent>
          <isNotEmpty prepend="and" property="Attach_ObjectModule">
            [Attach_ObjectModule] like '%$Attach_ObjectModule$%'
          </isNotEmpty>
          <isNotEmpty prepend="and" property="Attach_ObjectID">
            [Attach_ObjectID] like '%$Attach_ObjectID$%'
          </isNotEmpty>
        </isParameterPresent>
      </dynamic>
    </select>


    <insert id="InsertAttachment" parameterClass="hashtable" resultClass="int">
      INSERT INTO [Attachment]
      ([Attach_FileName]
      ,[Attach_Path]
      ,[Attach_ObjectID]
      ,[Attach_ObjectModule]
      ,[Attach_ContentType]
      ,[Attach_Size]
      ,[Attach_IsTemp]
      ,[Attach_CreateTime]
      ,[Attach_CreateUserName])
      VALUES
      (#Attach_FileName#,
      #Attach_Path#,
      #Attach_ObjectID#,
      #Attach_ObjectModule#,
      #Attach_ContentType#,
      #Attach_Size#,
      #Attach_IsTemp#,
      #Attach_CreateTime#,
      #Attach_CreateUserName#)
      <selectKey resultClass="int" Property="Attach_ID" type="post">
        SELECT @@IDENTITY AS value
      </selectKey>
    </insert>
    <delete id="DeleteAttachment" parameterClass="string" resultClass="int">
      DELETE FROM [Attachment]
      WHERE [Attach_ID]  in
      <iterate   property="ids" open="(" close=")"  conjunction=",">
        #ids[]#
      </iterate>
    </delete>

    <select id="GetAttachment" parameterClass="string" resultClass="Kaiser.Modules.Hiner.Models.Product.Attachment">
      SELECT [Attach_ID]
      ,[Attach_FileName]
      ,[Attach_Path]
      ,[Attach_ObjectID]
      ,[Attach_ObjectModule]
      ,[Attach_ContentType]
      ,[Attach_Size]
      ,[Attach_IsTemp]
      ,[Attach_CreateTime]
      ,[Attach_CreateUserName]
      FROM [Attachment]
      WHERE [Attach_ID] =#Attach_ID#
    </select>

    <!--上传附件结束  何航-->
  </statements>
</sqlMap>

